# import pygame
import pygame
from pygame.locals import *

# main keyboard class
class KeyboardHandler(object):
    "this handles keyboard inputs"
    def __init__(self):
        self.w = ord('w')
        self.s = ord('s')
        self.a = ord('a')
        self.d = ord('d')
        self.escape = K_ESCAPE
        self.up = False
        self.down = False
        self.left = False
        self.right = False
        self.quit = False

    def check_input(self):
        for event in pygame.event.get():
            if event.type == QUIT:
                self.quit = True
            if event.type == KEYDOWN:
                if event.key == self.escape:
                    self.quit = True
                if event.key == self.w:
                    self.up = True
                if event.key == self.s:
                    self.down = True
                if event.key == self.a:
                    self.left = True
                if event.key == self.d:
                    self.right = True
            if event.type == KEYUP:
                if event.key == self.w:
                    self.up = False
                if event.key == self.s:
                    self.down = False
                if event.key == self.a:
                    self.left = False
                if event.key == self.d:
                    self.right = False
